/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ftpcombiner.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JProgressBar;

/**
 *
 * @author Ben
 */
public class SplashScreen extends JDialog implements GUILoader {

    private int increment = 100 / 16;
    private int progress = 0;
    private JProgressBar progressBar;
    private JLabel imageLabel;

    public SplashScreen() {
        init();
    }

    public void incrementProgress() {
        if (progress <= 100 - increment) {
            progress += increment;
            progressBar.setValue(progress);
        }
    }

    private void init() {
        initializeComponents();
        setLayouts();
        addComponents();
        addComponentListeners();
        otherInit();
    }

    @Override
    public void initializeComponents() {
        progressBar = new JProgressBar();
        imageLabel = new JLabel(GUIResources.getInstance().getSplashImage());
    }

    @Override
    public void setLayouts() {
        setLayout(new BorderLayout());
    }

    @Override
    public void addComponents() {
        setPreferredSize(new Dimension(350, 120));
        progressBar.setPreferredSize(new Dimension(350, 20));
        imageLabel.setPreferredSize(new Dimension(350, 100));
        add(imageLabel, BorderLayout.NORTH);
        add(progressBar, BorderLayout.SOUTH);
        revalidate();
    }

    @Override
    public void addComponentListeners() {
    }

    @Override
    public void otherInit() {
        setUndecorated(true);
        pack();
        //setAlwaysOnTop(true);
        setLocationRelativeTo(null);
        setVisible(true);
    }
}
